/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.sgf.dt.spi;

import com.inspur.edp.lcm.metadata.api.entity.GspMetadata;
import com.inspur.edp.lcm.metadata.api.entity.uri.MetadataURI;
import com.inspur.edp.sgf.api.common.SummaryInfo;
import com.inspur.edp.sgf.api.entity.ServiceOperation;
import io.iec.edp.caf.multicontext.annotation.Collect;

import java.util.List;

/**
 * 功能描述:设计时的资源适配接口
 *
 * @author Fynn Qi
 * @author Kaixuan Shi
 * @version 1.1
 * @since 2020/8/26 14:42
 */
@Collect
public interface ResourceProvider {

    /**
     * 获取操作的概要信息集合
     *
     * @param targetMdURI 资源元数据uri
     * @param sourceMdURI 引用资源元数据的元数据uri
     * @param projectPath 工程路径
     * @return 返回值
     */
    List<SummaryInfo> getSummaryOperations(MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath);

    /**
     * 获取操作的集合
     *
     * @param targetMdURI 资源元数据uri
     * @param sourceMdURI 引用资源元数据的元数据uri
     * @param projectPath 工程路径
     * @return 返回值
     */
    List<ServiceOperation> getOperations(MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath);

    /**
     * 获取指定操作的集合
     *
     * @param targetMdURI  资源元数据uri
     * @param sourceMdURI  引用资源元数据的元数据uri
     * @param projectPath  工程路径
     * @param operationIds 资源操作ID集合
     * @return 返回值
     */
    List<ServiceOperation> getOperations(MetadataURI targetMdURI, MetadataURI sourceMdURI, String projectPath, List<String> operationIds);

    /**
     * 创建EAPI
     *
     * @param metadata 依赖的元数据
     * @param path     创建EAPI的目标路径
     * @return EAPI元数据
     */
    GspMetadata create(GspMetadata metadata, String path);

    /**
     * 创建元数据
     * 使用场景：创建元数据到DB
     *
     * @param metadata 依赖的元数据实体，如视图对象
     * @return 外部服务元数据实体
     */
    GspMetadata create(GspMetadata metadata);

    /**
     * 更新元数据
     *
     * @param eapiMetadataId 外部服务元数据ID
     * @param metadata       外部服务元数据实体
     * @return 更新后的外部服务元数据实体
     */
    GspMetadata update(String eapiMetadataId, GspMetadata metadata);

}
